<?php

use App\Http\Controllers\IndexController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\RunErrandController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\WeChatLoginController;
use App\Http\Controllers\WechatPaymentController;
use App\Http\Controllers\WithdrawFundController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laravel\Sanctum\PersonalAccessToken;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::post('wechat/login', [WeChatLoginController::class, 'login']);
Route::post('upload', [UploadController::class, 'upload']);
Route::get('remove-blacklist', [IndexController::class, 'removeBlacklist']);
Route::post('wechat-pay/notify-url', [WechatPaymentController::class, 'handlePaymentCallback']);
Route::get('wechat-pay/auto-refund', [WechatPaymentController::class, 'refundOrder']);
Route::prefix('common')->group(function () {
    Route::get('/school-list', [IndexController::class, 'schoolList']);
    Route::get('/school', [IndexController::class, 'index']);
    Route::get('/customer-phone', [IndexController::class, 'customer']);
    Route::get('/customer-phone', [IndexController::class, 'customer']);
    Route::get('/disclaimer', [IndexController::class, 'disclaimer']);
    Route::get('/withdrawal-instructions', [IndexController::class, 'withdrawalInstructions']);
});


Route::middleware('auth:sanctum')->group(function () {

    Route::prefix('user')->group(function () {
        Route::get('/personal-profile', [UserController::class, 'index']);
        Route::post('/update', [UserController::class, 'update']);
        Route::post('/login-out', [UserController::class, 'loginOut']);
        Route::get('/proceed-list', [UserController::class, 'proceedList']);
        Route::get('/order-list', [UserController::class, 'orderList']);
        Route::post('/cancel', [UserController::class, 'cancelOrder']);
        Route::post('/feedback', [UserController::class, 'feedback']);
    });

    //提现
    Route::prefix('withdraw-fund')->group(function () {
        Route::get('/index', [WithdrawFundController::class, 'index']);
        Route::get('/withdraw', [WithdrawFundController::class, 'withdraw']);
        Route::post('/store', [WithdrawFundController::class, 'store']);
    });

    //任务
    Route::prefix('task')->group(function () {
        Route::get('/index', [OrderController::class, 'index']);
        Route::get('/list', [OrderController::class, 'orderList']);
        Route::get('/detail', [OrderController::class, 'detail']);
        Route::post('/store', [OrderController::class, 'store']);
        Route::post('/cancel', [OrderController::class, 'cancelOrder']);
        Route::post('/complete', [OrderController::class, 'completeOrder']);
        Route::post('/take-order', [OrderController::class, 'takeOrder']);
    });
    Route::get('/run-errand', [RunErrandController::class, 'detail']);
    Route::post('/apply-run-errand', [RunErrandController::class, 'apply']);

});
